#pragma once
#include "Singleton.h"
#include "ObjectFactory.h"
#include <map>
//////////////////////////////////////////////////////////////////////////

class CPropHolder;
class GEOMUIAPI CPropCreator
{
public:
	virtual CPropHolder* Create(void) = 0;
};

//////////////////////////////////////////////////////////////////////////
class CAnyView;

class GEOMUIAPI CPropFactory
	: public ATools::TSingleton<CPropFactory>,
	public ATools::TObjectFactory<CPropHolder, CString, CPropCreator>
{
public:
	CPropFactory(void);
	~CPropFactory(void);
	void Initialize(void);
	CPropHolder* CreateProp(const CString& szId);
	void AddPropScript(const CString& szID, const CString& szScript);
private:
	bool FindPropScritp(const CString& szID, CString& szScript);

private:
	typedef std::map<CString, CString> PropMaps;
	PropMaps m_PropScrips;
};

inline CPropFactory& GetPropFactory()
{
	return CPropFactory::Instance();
}

//////////////////////////////////////////////////////////////////////////

class GEOMUIAPI CRegPropHelper
{
public:
	CRegPropHelper(const CString& guid, CPropCreator* pPropCreator);
	~CRegPropHelper();
protected:
	void RegisterProp(CPropCreator* pPropCreator);
	const CString& m_Guid;
};

#define REGISTERE_PROP(Prop) \
	static CRegPropHelper s_regPropHelper##Prop(Prop::GetID(),\
	new ATools::TObjectCreator<Prop, CPropCreator>());


